/* See LICENSE for copyright and terms of use */

import org.evtmng.*;
import org.evtmng.events.*;
import org.evtmng.timeline.*;
import org.evtmng.tween.*;
import org.evtmng.test.FadeBoxUtil;

/**
 * This is an example of using the timeline elements to handle multiple scripted tweens.
 *
 * @author Tay Ray Chuan
 */

class org.evtmng.test.DiagonalFadeBox_twn extends FadeBoxUtil {

	private var m_twn_mgr:TweenManager;
	
	/**
	 * Entrypoint
	 */
	public static function main() : Void {
		var inst:DiagonalFadeBox_twn = new DiagonalFadeBox_twn();
		inst.init(_root.createEmptyMovieClip("fadeboxholder", _root.getNextHighestDepth()));
		inst.run();
	}
	
	/**
	 * Creates timeline elements.
	 */
	public function DiagonalFadeBox_twn() {
		m_twn_mgr = TweenManager.instance();
		m_twn_mgr.timelineManager().setTimeInterval(INTERVAL);
	}
	
	/**
	 * Tells TweenManager to create a new tween. We don't really concern ourselves with
	 * mundane details of how tween actually takes place, we just want one that starts
	 * and ends at some given time, changes some value, etc.
	 *
	 * @see org.evtmng.tween.TweenManager.tweenObjectPropertyEaserBeginChangeStartEnd
	 */
	private function handleTweenAddition(sum:Number, mc:MovieClip):Void {
		TweenManager.tweenObjectPropertyEaserBeginChangeStartEnd(
		m_twn_mgr.tweenObjectPropertyEaserBeginChangeStartEnd(
		mc, "_alpha", EASE, 99, -98, sum, sum+Math.round(DURATION/INTERVAL));
	}

	public function run():Void {
		m_twn_mgr.run();
	}
}
